<template>
  <div>
    <MainFrame menuIndex="SignInfoList">
      <div slot='content'>
        <div class="top-title">
          签单信息详情
        </div>
        <div class="top-button">
          <el-button type="primary" @click="back">返回</el-button>
        </div>
        <ttForm v-model="form"></ttForm>
      </div>
    </MainFrame>
  </div>
</template>
<script>
import MainFrame from '@/components/MainFrame'
import utils from '../ttJs/utils.js'
import ttForm from '@/tt_components/ttForm'
export default {
  components: {
    MainFrame,
    ttForm
  },
  data() {
    var validator = (rule, value, callback) => {
      callback();
    };
    return {
      form: {
        id: null,
        url: '/ay/editor/submitSignInfo',
        items: [
          { name: 'no', value: '', label: '合同编号', placeholder: '请输入合同编号', type: 'input', rules: true, msg: '编号不能为空' },
          { name: 'name', value: '', label: '姓名', placeholder: '请输入姓名', type: 'input' },
          { name: 'employer', value: '', label: '雇佣人', placeholder: '请输入雇佣人', type: 'input' },
          { name: 'city', value: '', label: '城市', placeholder: '请输入城市', type: 'input' },
          { name: 'shop', value: '', label: '门店', placeholder: '请输入门店', type: 'input' },
          { name: 'type', value: '', label: '类型', placeholder: '请输入类型', type: 'input' },
          { name: 'mobile', value: '', label: '电话', placeholder: '请输入电话', type: 'input' },
          { name: 'bookDate', value: '', label: '日期', placeholder: '请输入日期', type: 'input' }
        ],
        rules: {
          no: [{ required: true, validator: validator, trigger: 'blur' }]
        }
      },
    };
  },
  mounted: function() {
    this.getInfo()
  },
  methods: {
    getInfo() {
      var self = this;
      var id = self.$route.query.id
      if (utils.validateData(id)) {
        self.form.id = id;
        var url = '/ay/editor/signInfo';
        var params = { id: id }
        var success = function(response) {
          var info = response.info;
          var items = self.form.items
          for (var index in items) {
            for (var key in info) {
              if (items[index].name == key) {
                if (items[index].type == 'img') {
                  if (utils.validateData(info[key])) {
                    items[index].imgUrl = info[key];
                  }
                }
                items[index].value = info[key]
              }
            }
          }
        }
        var fail = function() {
          utils.fail('加载失败')
        }
        var complete = function() {}
        utils.requestLoading(url, params, success, fail, complete)
      }
    },
    back() {
      window.history.back();
    }
  }
};

</script>
<style scoped rel="stylesheet/scss" lang="scss">
.top-title {
  margin: 0 0 20px 150px;
  font-size: 18px;
  font-weight: bold;
}

.top-button {
  margin: 0 0 20px 150px;
}

</style>
